/**********************************************************************
 * Project : WoWGuildRoster (http://www.codeplex.com/WowGuildRoster/)
 * Module  : DotNetWarcraft.WoWGuildRoster.Business.GuildRosterModule
 **********************************************************************
 * 
 * 
 * 
 **********************************************************************
 * License : All code is subject to licensing terms per the Microsoft
 *   Permissive License (Ms-PL) v1.1. For full license information,
 *   refer to the packaged license.txt file.
 **********************************************************************
 * Revision History:
 * -----------------
 * 2007-08-20 -- Cliff Simpkins: Initial Version
 **********************************************************************
 */
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using DotNetWarcraft.Common;

namespace DotNetWarcraft.WoWGuildRoster.Business {
  /// <summary>
  /// Roster mapping to a DNN module.
  /// </summary>
  public class GuildRosterModule {
    #region Protected Members
    protected int _module_id;
    protected int _portal_id;
    protected int _roster_id;
    protected int _can_load_lua;
    protected bool _show_guild;
    protected String _guild_name;
    #endregion
    #region Public Properties
    public int Module_ID {
      get {
        return _module_id;
      }
      set {
        _module_id = value;
      }
    }
    public int Portal_ID {
      get {
        return _portal_id;
      }
      set {
        _portal_id = value;
      }
    }

    public int Roster_ID {
      get {
        return _roster_id;
      }
      set {
        _roster_id = value;
      }
    }

    public String Guild_Name {
      get {
        return _guild_name;
      }
      set {
        _guild_name = value;
      }
    }
    public int Can_Load_LUA {
      get {
        return _can_load_lua;
      }
      set {
        _can_load_lua = value;
      }
    }

    public bool Show_Guild_Bool {
      get {
        return _show_guild;
      }
      set {
        _show_guild = value;
      }
    }
    #endregion
    #region Public Interpreted Properties
    public bool Can_Load_LUA_Bool {
      get {
        return (this.Can_Load_LUA > 0);
      }
      set {
        if (value) {
          this.Can_Load_LUA = 1;
        } else {
          this.Can_Load_LUA = 0;
        }
      }
    }
    #endregion

    #region Constructors
		public GuildRosterModule() : base() {
      this.Module_ID = -1;
      this.Portal_ID = -1;
      this.Roster_ID = -1;
      this.Guild_Name = "";
      this.Can_Load_LUA = 0;
    }
    public GuildRosterModule(int moduleID, int portalID, int rosterID, String guildName, bool canLoadLua) : this() {
      this.Module_ID = moduleID;
      this.Portal_ID = portalID;
      this.Roster_ID = rosterID;
      this.Guild_Name = guildName;
      this.Can_Load_LUA_Bool = canLoadLua;
    }

    public GuildRosterModule(DataRow rosterModSrc) : base() {
      this.Module_ID = SqlDataUtils.RetrieveDbInt(rosterModSrc["module_id"]);
      this.Portal_ID = SqlDataUtils.RetrieveDbInt(rosterModSrc["portal_id"]);
      this.Roster_ID = SqlDataUtils.RetrieveDbInt(rosterModSrc["roster_id"]);
      this.Can_Load_LUA = SqlDataUtils.RetrieveDbInt(rosterModSrc["can_load_lua"]);

      //Checking the column's presence, because not all data rows passed are guaranteed to have a guild name attached
      if (rosterModSrc.Table.Columns.Contains("guild_name")) {
        this.Guild_Name = SqlDataUtils.RetrieveDbString(rosterModSrc["guild_name"]);
      } else { this.Guild_Name = ""; }

    }

    #endregion
  }
}
